package cn.lumora.core.exception;


import cn.lumora.core.dto.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import redis.clients.jedis.Jedis;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public ApiResponse<String> handleBusinessException(BusinessException ex) {
        return new ApiResponse<>(400, ex.getMessage(), null);
    }

    @ExceptionHandler(Exception.class)
    public ApiResponse<String> handleUnexpectedError(Exception ex) {
        log.error("Unexpected error occurred: ", ex);
        return new ApiResponse<>(500, "系统异常，请稍后重试", null);
    }
}
